package com.zha.boss.mvc.convert;

import com.zha.boss.dao.entity.UserInfo;
import com.zha.boss.mvc.models.vo.UserInfoMatchVo;
import com.zha.boss.mvc.models.vo.UserInfoVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;

import java.util.List;

/**
 * @Author: zha
 * @CreateTime: 2024年09月12日 18:29
 */
@Mapper(componentModel = "spring")
public interface UserConvert {
    List<UserInfoVo> mapListUserInfoVo(List<UserInfo> userInfoList);
    List<UserInfoMatchVo> mapListUserInfoMatchVo(List<UserInfo> userInfoList);

    // 转换userInfo
    @Mappings({
            @Mapping(source = "createTime", target = "createTime",dateFormat = "yyyy-MM-dd HH:mm:ss"),
            @Mapping(source = "status",target = "status",qualifiedByName = "transStatus"),
    })
    UserInfoVo toUserInfoVo(UserInfo userInfo);

    // 转换userInfoMatch

    UserInfoMatchVo toUserInfoMatchVo(UserInfo userInfo);

    // 处理状态(status)
    @Named ("transStatus")
    default String transStatus(String status) {
        if ("DISABLE".equals(status)){
            return "禁用";
        }else if ("ENABLE".equals(status)){
            return "启用";
        }
        return "未知";
    }
}
